package com.seeqool.v1.dataviews;

import org.jfree.data.DomainOrder;
import org.jfree.data.xy.XYDataset;

import com.seeqool.v1.datamodel.SQLTable;

public class XYView extends BaseView implements XYDataset {
	
	private float[]      dataX;
	private float[][]    dataY;

	public XYView(SQLTable table, int majorAxis, Integer[] minorAxes) {
		dataX = table.getFloats(majorAxis);
		dataY = new float[minorAxes.length][];
		for (int axis=0; axis<minorAxes.length; axis++) {
			dataY[axis] = table.getFloats(minorAxes[axis]);
		}
	}
	
	public DomainOrder getDomainOrder() { return DomainOrder.NONE; }

	public int getSeriesCount()         { return dataY.length; }
	public int getItemCount(int series) { return dataX.length; }

	public Number getX     (int series, int item) { return dataX[item]; }
	public Number getY     (int series, int item) { return dataY[series][item];	}
	public double getXValue(int series, int item) {	return dataX[item];	}
	public double getYValue(int series, int item) {	return dataY[series][item]; }

	public Comparable<String> getSeriesKey(int series) {
		return "Hello "+series;
	}

	@SuppressWarnings("unchecked")
	public int indexOf(Comparable seriesKey) {
		return 0;
	}
}
